package nimble.maxwoods.regx; /**
 * @description:
 * @authoer: Max Woods
 * @create:2018/6/25 14:46
 **/


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 *@auther: Max Woods
 *@create:2018/6/25 14:46
 **/
public class RegX {

    private static final Logger logger=LoggerFactory.getLogger(RegX.class);

    final static Pattern fileFilterPattern = Pattern.compile(".*\\.(zip|mp4|exe|css)\\?.*$",Pattern.CASE_INSENSITIVE);
    final static Pattern NoDataPagePattern = Pattern.compile(".*(check.jsp|contact.jsp|yewufanchou.jsp|reg.jsp|/hyd/|chat.jsp|fazhanlishi.jsp|/lpai/|info.jsp).*$",Pattern.CASE_INSENSITIVE);
    final static Pattern DataPagePattern = Pattern.compile(".*((.jsp)?\\?G=.*|(.jsp)?\\?T=.*\\&G=.*|(.jsp)?\\?P=.*\\&G=.*|(.jsp)?\\?OBY=.*\\&G=.*)",Pattern.CASE_INSENSITIVE);

    public static void main(String[] args)
    {
        logger.info("=======开始匹配=======");
        List<String> urls=new ArrayList<>();
        urls.add("http://www.huayicang.com/hxgq/hyd/v234.exe?id=2");
        urls.add("http://www.huayicang.com/hxgq/hyd/asdf.css?v=20034");
        urls.add("http://www.huayicang.com/hxgq/hyd/company.html");
        urls.add("http://www.huayicang.com/hxgq/help/check.jsp");
        urls.add("http://www.huayicang.com/hxgq/us/index.jsp");
        urls.add("http://www.huayicang.com/hxgq/hyd/");
        urls.add("http://www.huayicang.com/hxgq/user/reg.jsp");
        urls.add("http://www.huayicang.com/hxgq/cop/info.jsp?ID=3008");
        urls.add("http://www.huayicang.com/hxgq/baike/info.jsp?id=1222");
        urls.add("http://www.huayicang.com/hxgq/us/fazhanlishi.jsp");
        urls.add("http://www.huayicang.com/hxgq/us/contact.jsp");
        urls.add("http://www.huayicang.com/hxgq/us/yewufanchou.jsp");
        urls.add("http://www.huayicang.com/hxgq/us/yewuliucheng.jsp");
        urls.add("http://www.huayicang.com/hxgq/us/chubanwu.jsp");
        urls.add("http://www.huayicang.com/hxgq/cop/info.jsp?ID=1048");
        urls.add("http://www.huayicang.com/hxgq/show/view.jsp?stype=%5b%c8%fd%b9%fa%c1%bd%bd%fa%c4%cf%b1%b1%b3%af%5d%5b%b6%ab%bd%fa%ca%ae%c1%f9%b9%fa%5d");
        //===================================================================
        urls.add("http://www.huayicang.com/hxgq/xpai/index.jsp?G=25621");
        urls.add("http://www.huayicang.com/hxgq/xpai/index.jsp?T=%CB%E5%2C%CC%C6%2C%CE%E5%B4%FA&G=25461");
        urls.add("http://www.huayicang.com/hxgq/xpai/index.jsp?P=6&G=25461");
        urls.add("http://www.huayicang.com/hxgq/xpai/index.jsp?OBY=1&G=25461");
        for(String url:urls)
        {
            if(fileFilterPattern.matcher(url).matches())
            {
                logger.info("文件过滤:{}",url);
            }
            if(NoDataPagePattern.matcher(url).matches())
            {
                logger.info("非数据提取url:{}",url);
            }
            if(DataPagePattern.matcher(url).matches())
            {
                logger.info("数据提取url:{}",url);
            }
        }
    }
}
